/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-17 16:17:37
 * @LastEditTime : 2023-06-28 10:00:09
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\OrganizationIdentities.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const OrganizationIdentities = async ({ url, OptionsEvent, Permission }) => {
    const { hostname } = window.location
    let data = {
        type: '系统设置',
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            (hostname.includes('bada') ||
                Permission?.findIndex(v => v.uuid === '099c6163-3cda-4626-8230-53c1093d4b5d') !== -1) && (
                <AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增机构身份" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            commonTableList.tableName,
            { ...commonTableList.code, rules: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        (hostname.includes('bada') ||
                            Permission.findIndex(v => v.uuid === '0ff3f5a4-42b2-44f9-bd53-faff4008f57c') !== -1) && (
                            <ModDataButton
                                OptionsEvent={OptionsEvent}
                                key="modify"
                                title="修改"
                                url={url}
                                data={record}
                            />
                        ),
                        (hostname.includes('bada') ||
                            Permission.findIndex(v => v.uuid === '3f1b0f51-98d8-4987-8b7b-a5ae9accab41') !== -1) && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="delete"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
